package com.tshopping.dao;

import com.tshopping.bean.Comment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
public interface CommentDao {

    @Insert("insert into comment(user,time,content,detail,goods) values(#{user},#{time},#{content},#{detail},#{goods})")
    @Options(useGeneratedKeys = true, keyColumn = "id")
    boolean insertGoodsByGoodsInformation(Comment comment);

    @Select("select * from comment where goods=#{goods} limit #{start},#{size}")
    ArrayList<Comment> selectGoodsCommentsByGoodsId(@Param("goods")int goods,@Param("start")int start,@Param("size")int size);

    @Select("select count(*) from comment where goods=#{goods}")
    int selectCountByGoodsId(@Param("goods")int id);
}
